package com.my.xinyidaixi.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.my.xinyidaixi.DataBase.Model.Over_UserModer;
import com.my.xinyidaixi.DataBase.Model.UserModel;
import com.my.xinyidaixi.HttpVolley.Volley_core;
import com.my.xinyidaixi.R;

/**
 * Created by zw on 2017/6/8.
 */
public class feedback extends AppCompatActivity{

    private TextView qita,tijiao,fukuanliucheng,chanpinyiyongqi,wuliusudu,fuwutaidu,xihuzhiliang;
    private EditText edit;
    private UserModel model=new Over_UserModer();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.feedback);
        initdata();
    }

    public void initdata()
    {
        ImageView feedback_fanhui = (ImageView) findViewById(R.id.feedback_fanhui);
        feedback_fanhui.setOnClickListener(new Button());
        xihuzhiliang = (TextView) findViewById(R.id.feedback_xihuzhiliang);
        xihuzhiliang.setOnClickListener(new Button());
        fuwutaidu = (TextView) findViewById(R.id.feedback_fuwutaidu);
        fuwutaidu.setOnClickListener(new Button());
        wuliusudu = (TextView) findViewById(R.id.feedback_wuliusudu);
        wuliusudu.setOnClickListener(new Button());
        chanpinyiyongqi = (TextView) findViewById(R.id.feedback_chanpinyiyongxing);
        chanpinyiyongqi.setOnClickListener(new Button());
        fukuanliucheng = (TextView) findViewById(R.id.feedback_fukuanliucheng);
        fukuanliucheng.setOnClickListener(new Button());
        qita = (TextView) findViewById(R.id.feedback_qita);
        qita.setOnClickListener(new Button());
        tijiao = (TextView) findViewById(R.id.feedback_tijiao);
        tijiao.setOnClickListener(new Button());
        edit = (EditText) findViewById(R.id.feedback_edit);
    }

    public class Button implements View.OnClickListener
    {

        @Override
        public void onClick(View v) {
            switch (v.getId())
            {
                case R.id.feedback_fanhui:
                    feedback.this.finish();
                    overridePendingTransition(R.anim.ani_left_sign_out,0);
                    break;
                case R.id.feedback_xihuzhiliang:
                    clear();
                    xihuzhiliang.setBackgroundResource(R.drawable.feedback_button_click);
                    xihuzhiliang.setTextColor(getResources().getColor(R.color.cyan));
                    tijiao.setBackgroundResource(R.drawable.buttonselect_shape);
                    break;
                case R.id.feedback_fuwutaidu:
                    clear();
                    fuwutaidu.setBackgroundResource(R.drawable.feedback_button_click);
                    fuwutaidu.setTextColor(getResources().getColor(R.color.cyan));
                    tijiao.setBackgroundResource(R.drawable.buttonselect_shape);
                    break;
                case R.id.feedback_wuliusudu:
                    clear();
                    wuliusudu.setBackgroundResource(R.drawable.feedback_button_click);
                    wuliusudu.setTextColor(getResources().getColor(R.color.cyan));
                    tijiao.setBackgroundResource(R.drawable.buttonselect_shape);
                    break;
                case R.id.feedback_chanpinyiyongxing:
                    clear();
                    chanpinyiyongqi.setBackgroundResource(R.drawable.feedback_button_click);
                    chanpinyiyongqi.setTextColor(getResources().getColor(R.color.cyan));
                    tijiao.setBackgroundResource(R.drawable.buttonselect_shape);
                    break;
                case R.id.feedback_fukuanliucheng:
                    clear();
                    fukuanliucheng.setBackgroundResource(R.drawable.feedback_button_click);
                    fukuanliucheng.setTextColor(getResources().getColor(R.color.cyan));
                    tijiao.setBackgroundResource(R.drawable.buttonselect_shape);
                    break;
                case R.id.feedback_qita:
                    clear();
                    qita.setBackgroundResource(R.drawable.feedback_button_click);
                    qita.setTextColor(getResources().getColor(R.color.cyan));
                    tijiao.setBackgroundResource(R.drawable.buttonselect_shape);
                    break;
                case R.id.feedback_tijiao:
                    Volley_core Volley=new Volley_core();
                    if(model.count()==0)
                    {
                        Intent intent=new Intent();
                        intent.setClass(feedback.this,login_activity.class);
                        startActivity(intent);
                        feedback.this.overridePendingTransition(R.anim.ani_right_get_into,R.anim.ani_left_sign_out);
                    }
                    else
                    {
                        Volley.advise(model.getUser(),edit.getText().toString());
                    }
                    break;
            }
        }
    }
    public void clear()
    {
        xihuzhiliang.setBackgroundResource(R.drawable.feedback_button);
        xihuzhiliang.setTextColor(getResources().getColor(R.color.new_black));
        fuwutaidu.setBackgroundResource(R.drawable.feedback_button);
        fuwutaidu.setTextColor(getResources().getColor(R.color.new_black));
        wuliusudu.setBackgroundResource(R.drawable.feedback_button);
        wuliusudu.setTextColor(getResources().getColor(R.color.new_black));
        chanpinyiyongqi.setBackgroundResource(R.drawable.feedback_button);
        chanpinyiyongqi.setTextColor(getResources().getColor(R.color.new_black));
        fukuanliucheng.setBackgroundResource(R.drawable.feedback_button);
        fukuanliucheng.setTextColor(getResources().getColor(R.color.new_black));
        qita.setBackgroundResource(R.drawable.feedback_button);
        qita.setTextColor(getResources().getColor(R.color.new_black));
    }

    @Override
    protected void onPause() {
        super.onPause();
        feedback.this.overridePendingTransition(R.anim.ani_right_get_into,R.anim.ani_left_sign_out);
    }

}
